package com.huyirong.aicode.exception;

public class ThrowUtils {

    /**
     * 如果条件成立，就抛出异常
     * @param condition
     * @param runtimeException
     */
    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if(condition){
            throw runtimeException;
        }
    }

    /**
     *
     * @param condition
     * @param errorCode
     */
    public static void throwIf(boolean condition, ErrorCode errorCode){
        throwIf(condition,new BusinessExpection(errorCode));
    }

    public static void throwIf(boolean condition, ErrorCode errorCode, String message) {
        throwIf(condition,new BusinessExpection(errorCode,message));
    }
}
